<html>
<head>
<title>Help : Academic Advisor</title>
<!--script src="lib/jquery/jquery-1.3.2.js"--><!--/script-->
<!--script src="http://code.google.com/apis/gears/gears_init.js"--><!--/script-->
<!--script src="js/mainPage.js"--> <!--/script-->

<style type="text/css">
a:link {color:#FFFFFF;}    /* unvisited link */
.class1 a:link{color:#000000} /*for appointments*/
a:visited {color:#FF0000;} /* visited link */
a:hover {color:#FFFF00;}   /* mouse over link */
a:active {color:#FF8040;}  /* selected link */
</style>

</head>
<!--------------------------------------------------------Design part of the code---------------------------------------------->
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginheight="0" marginwidth="0" bgcolor="#000066">

<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#000066">
  <tr>
  <td><img src="../images/jsu_banner.jpg"></td>
  </tr>
</table>

<table border="0" width="100%" bgcolor="#000000" cellspacing="0" cellpadding="0">
  <tr>
  <center><td width="100%"><font color="#FFFFFF" face="Arial" size="2"><b>D.O.R.S. Jackson State University Edition</b></font></td></center>
     <?php
	session_start();
	$JNo = $_SESSION['JNo'];
	echo "<center><td width='100%'><font color='#FFFFFF' face='Arial' size='2'><b>JSU ID: $JNo</b></font></td></center>";
  ?>
  </tr>
</table>

<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td width="18%" bgcolor="#000066" valign="top">&nbsp;


<!------------------------------------------End of Design-------------------------------------------------------->


<center>
<img src="../images/logo.jpg">
</center>

<center>
<img src="../images/courses_sign.jpg">
</center>

<center>
<table>
<tr>
<td><b><a href="http://localhost/OnlineSystem/WebContent/financialAidPage.php">Financial Aid</b></a></td>
<td><b><a href="http://localhost/OnlineSystem/WebContent/accountSummaryPage.php">Account Summary</b></a></td>
<td><b><a href="http://localhost/OnlineSystem/WebContent/purchaseBookPage.php">Purchase Your Books</b></a></td>
<td><b><a href="http://localhost/OnlineSystem/WebContent/selectCourses.php">Choose Courses</b></a></td>
</tr>
</table>
</center>


<center>
<!-- Course Page -->
<table border="3" width="25%" cellspacing="0" cellpadding="0" bgcolor="#F0F8FF">
<tr>
<td><b>Time</b></td>
<td><b>Status</b></td>
</tr>


<tr>
	<td>
		<!-- Something about Selecting an advisor -->
	</td>
	<?php
		function get_column_names_with_show ($tbl_name){
		$query = "SHOW COLUMNS FROM $tbl_name";
		if (!($result_id = mysql_query ($query)))
			return (FALSE);
		$names = array( );               # create empty array
		# first value in each output row is the column name
		while (list ($name) = mysql_fetch_row ($result_id))
			$names[ ] = $name;           # append name to array
		mysql_free_result ($result_id);
		return ($names);
		}
		$host="localhost"; // Host name
		$username="root"; // Mysql username
		$password=""; // Mysql password
		$db_name="JSU_Database"; // Database name

		// Connect to server and select database.
		mysql_connect($host, $username, $password)or die("cannot connect");
		mysql_select_db($db_name)or die("cannot select DB: ".mysql_error());

		$advisors = $_POST['advisors'];
		for($i=0; $i<count($advisors); $i++){
			$result = mysql_query("SELECT Fname, Mname, Lname FROM academic_advisor WHERE JNo = '$advisors[$i]'");
			$row = mysql_fetch_row($result);
			echo "<font color='#FFFFFF' face='Arial' size='2'>$row[2], $row[0] $row[1]</font>";
			$result = mysql_query("SELECT * FROM acad_timetable WHERE AdvisorJNo = '$advisors[$i]'");
			$columns = get_column_names_with_show("acad_timetable");
			$currAdvisor = $advisors[$i];
			/*if (!$result)
				echo "<tr><td>No classes for this selection exist!</td></tr>";
			else {*/
			echo "<form name = 'appointmentList' id='appointmentList' method='post'>";
			while ($row = mysql_fetch_row($result)){
				for ($j = 1; $j <= 28; $j++){
					echo "<tr><td>$columns[$j]</td>";
					if ($row[$j] == "Occupied")
						echo "<td>Occupied</td>";
					else{
						$send = $columns[$j];
						echo "<td><span class='class1'><a href='setAppointment.php?time=$send&ajNo=$currAdvisor'>Available</a></span></td>";
					}echo "</tr>";
				}
			}
		}
	?>
</table>
</center>

<center>
<INPUT type="button" value="Back" name="button1" onClick="history.go(-1); return true;"> 
</FORM>
</center>

</body>
</html>